package com.supereye.platform.web.terminal.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.supereye.platform.base.BaseDao;
import com.supereye.platform.web.terminal.model.TopTerminal;

@Repository
public class TerminalDao extends BaseDao {
	public void addTerminal(TopTerminal terminal) throws Exception {
		sqlSessionTemplate.insert("com.supereye.platform.web.terminal.dao.TerminalDao.addTopTerminal", terminal);
	}

	public List<TopTerminal> getTerminalList(Map<String,Object> params) throws Exception {
		return sqlSessionTemplate.selectList("com.supereye.platform.web.terminal.dao.TerminalDao.queryTerminal", params);
	}

	public void deleteTerminals(String[] terminalIds) throws Exception {
		List<Object[]> params = new ArrayList<Object[]>();
		for(String terminalId:terminalIds){
			params.add(new String[]{terminalId});
		}
		jdbcTemplate.batchUpdate("delete from top_terminal where id=?", params);
	}

	public void updateTerminal(TopTerminal terminal) throws Exception {
		sqlSessionTemplate.update("com.supereye.platform.web.terminal.dao.TerminalDao.updateTopTerminal", terminal);
	}

	public Integer getTerminalListCount(Map<String, Object> params) throws Exception {
		return sqlSessionTemplate.selectOne("com.supereye.platform.web.terminal.dao.TerminalDao.queryTerminalCount", params);
	}
}
